/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.unesp.ia.gridsolver.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Pardal
 */
@Entity
@Table(name = "curso", catalog = "cursos", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Curso.findAll", query = "SELECT c FROM Curso c"),
    @NamedQuery(name = "Curso.findByIdCurso", query = "SELECT c FROM Curso c WHERE c.idCurso = :idCurso"),
    @NamedQuery(name = "Curso.findByNome", query = "SELECT c FROM Curso c WHERE c.nome = :nome"),
    @NamedQuery(name = "Curso.findByNIdealSemestres", query = "SELECT c FROM Curso c WHERE c.nIdealSemestres = :nIdealSemestres"),
    @NamedQuery(name = "Curso.findByNMaxSemestres", query = "SELECT c FROM Curso c WHERE c.nMaxSemestres = :nMaxSemestres")})
public class Curso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idCurso", nullable = false)
    private Integer idCurso;
    @Size(max = 45)
    @Column(name = "Nome", length = 45)
    private String nome;
    @Lob
    @Size(max = 65535)
    @Column(name = "Descricao", length = 65535)
    private String descricao;
    @Column(name = "nIdealSemestres")
    private Integer nIdealSemestres;
    @Column(name = "nMaxSemestres")
    private Integer nMaxSemestres;
    @ManyToMany(mappedBy = "cursoList")
    private List<Aluno> alunoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "curso")
    private List<Materia> materiaList;

    public Curso() {
    }

    public Curso(Integer idCurso) {
        this.idCurso = idCurso;
    }

    public Integer getIdCurso() {
        return idCurso;
    }

    public void setIdCurso(Integer idCurso) {
        this.idCurso = idCurso;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Integer getNIdealSemestres() {
        return nIdealSemestres;
    }

    public void setNIdealSemestres(Integer nIdealSemestres) {
        this.nIdealSemestres = nIdealSemestres;
    }

    public Integer getNMaxSemestres() {
        return nMaxSemestres;
    }

    public void setNMaxSemestres(Integer nMaxSemestres) {
        this.nMaxSemestres = nMaxSemestres;
    }

    @XmlTransient
    public List<Aluno> getAlunoList() {
        return alunoList;
    }

    public void setAlunoList(List<Aluno> alunoList) {
        this.alunoList = alunoList;
    }

    @XmlTransient
    public List<Materia> getMateriaList() {
        return materiaList;
    }

    public void setMateriaList(List<Materia> materiaList) {
        this.materiaList = materiaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCurso != null ? idCurso.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Curso)) {
            return false;
        }
        Curso other = (Curso) object;
        if ((this.idCurso == null && other.idCurso != null) || (this.idCurso != null && !this.idCurso.equals(other.idCurso))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.unesp.ia.gridsolver.entity.Curso[ idCurso=" + idCurso + " ]";
    }
    
}
